1. Field of the Invention
This invention relates generally to video processing and more particularly to providing a real-time shading model for rendering objects on a display.
2. Description of the Related Art
Game developers are constantly refining image synthesis to create a technique that presents a realistic visual impression for users. One aspect of image synthesis that is used to present a realistic visual impression is the accurate portrayal of shadows and shading. Normal lighting for computer games rely on vector dot product calculations, which are relatively simple, but inaccurate. While the vector dot product calculations are able to present hard edge shadows, theses type of calculations cannot present soft edge shadows.
FIG. 1A is a schematic diagram representing an exemplary lighting computation scheme for rendering a display. Light source 100 includes a number of points that emit light. Occlusion surface 102 blocks a portion of the light from light source 100 that is directed to surface 104. Thus, a hard edge shadow (the umbra) is defined by region 106 from occlusion surface 102. However, point 110, which lies in soft shadow region (or penumbra) 108, requires that multiple points on light source 100 be picked out and the shadow projection for each of the points is determined. Each of the shadow projections is then summed, therefore, with respect to point 110 the summation of a number of lighting functions is required to realistically display points in soft shadow region 108. However, the calculation and summation of the lighting functions are computationally intensive and not viable alternatives for presenting realistic shading in real time. Furthermore, adding another light source, which is common especially in video games, requires another complete calculation.
One attempt to address this shortcoming is the use of a special case list which may be used to define the shading properties when certain criteria are met. However, the special case list is not exhaustive and as a result the list must be updated for each new situation. Moreover, the attempt to force a particular situation to fit a special case may result in sub-optimal display quality. Additionally, the special case list acts as a restriction on the game developer.
A ray tracer is a piece of software that is used to represent 3 dimensional data as an image. Unlike traditional polygonal 3-D engines, ray tracers excel at rendering curved surfaces, shadows and reflections. It is for these reasons that ray tracing has long been the method of choice for professionally rendered 3-D graphics and movie special effects. This greater functionality comes at the price of speed, which is why, ray tracers could not be used in real-time to define shading characteristics for a lighting function.
FIG. 1B is a simplified schematic diagram illustrating a ray tracing technique applied to visibility testing. Ray tracing works by projecting a ray of vision through each pixel on screen 101 from observer 103. It should be appreciated that where rays defined between ray 103-1 and ray 103-2 intersect object 105a, projected object 105b appears on screen 101. Generally, ray tracing uses objects that can be defined mathematically by 1st of 2nd degree equations. For every pixel on screen 101, an equation involving the ray through that pixel from observer 103 and each object in the scene is solved to determine if the corresponding ray intersects the object. Then, the pixel through which the ray passes is set to the color of the intersected object at the point of intersection. If more than one object is intersected, then the closer of the intersections is taken.
Reflections and shadows are achieved through what is known as recursive ray tracing. When figuring out the color of the intersection, one important factor is whether that point is in shadow, e.g., 107a and 107b, or not. To find this out, the same techniques are used, but instead of the normal location of the observer, the ray starts at the point of intersection and moves toward any light sources, such as light source 109. If the ray intersects something, then the point is in shadow. When a reflective surface is intersected, a new ray is traced starting from the point of intersection. The color that this ray returns is incorporated into the color of the original intersection. The process is called recursive because reflected rays, such as reflected ray 111 may spawn more reflected rays as long as the rays keep intersecting reflective objects.
To generate an image, mathematical rays are “fired” from a common origin (the camera or observer) through each pixel on the screen. Each ray is tested against each object in the scene to determine if the ray intersects the object. The distance from the observer to the intersections is calculated and the color of the closest intersected object is used for the pixel through which the ray is fired. However, due to the high computational cost associated with ray tracing, especially when interreflecting light between surfaces, ray tracing has not been a viable alternative for providing global illumination, e.g., soft shadows and self interreflection, in real time.
As a result, there is a need to solve the problems of the prior art to provide a method and apparatus for enabling ray tracing to be utilized for high quality lighting calculations where the result is rendered as polygons in real time.